home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / prog / lb09c.zip / SUMMARY.TXT < prev    next >
Text File  |  1992-12-03  |  52KB  |  1,759 lines

  1.  
  2. This file describes the many commands and functions of Liberty BASIC.  
  3. The format goes like this:
  4.  
  5.  
  6. Command/Function Name and Syntax  optional items in gray
  7.  
  8.  
  9. Description:
  10.     a short, exact specification for the command/function
  11.  
  12. Usage:
  13.     an example of how to use the function command in a short
  14.     Liberty BASIC program fragment
  15.  
  16.  
  17.  
  18. Explore the included Liberty BASIC source files for more information.
  19.  
  20.  
  21. See the section at the end of this file about commands for controlling
  22. the spreadsheet, graphics, and text windows.
  23.  
  24.  
  25. NOTE: This file is designed to be dumped to a printer with FF characters
  26.       to place each statement or function at the top of the next page.
  27.       For most, this is accomplished simply enough:
  28.  
  29.       C:\LIBERTY>type summary.txt > lpt1:
  30.  
  31.       or you could simply print this file from the Windows Notepad
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. ASC( n$ )
  40.  
  41. Description:
  42.  
  43.   This function returns the ASCII value of the first character of string n$.
  44.  
  45. Usage:
  46.  
  47.   print asc( "A" )              produces:  65
  48.  
  49.   let name$ = "Tim"
  50.   firstLetter = asc(name$)
  51.   print firstLetter             produces:  84
  52.  
  53.   print asc( "" )               produces:  0
  54.  
  55. BEEP
  56.  
  57. Description:
  58.  
  59.   This command simply rings the system bell, as in CTRL-G
  60.  
  61. Usage:
  62.  
  63.   .
  64.   .
  65. [loop]
  66.   input "Give me a number between 1 and 10?"; number
  67.   if number < 1 or number > 10 then beep : print "Out of range!" : goto [loop]
  68.   print "The square of "; number; " is "; number ^ 2
  69.   .
  70.   .
  71.  
  72.  
  73. BUTTON #handle, label, return, corner, posx, posy
  74.  
  75. Description:
  76.  
  77.   This statement lets you add buttons to windows that you open.  The main 
  78.   program window cannot have buttons added, but any window that you create 
  79.   via the OPEN command can have as many buttons as you want.  In this release 
  80.   of Liberty BASIC, buttons cannot have graphic pictures on them, but only 
  81.   text labels.  This will be remedied in a future release.
  82.  
  83. Usage:
  84.  
  85.   Before you actually OPEN the window, each button must be declared with a 
  86.   BUTTON statement.  Here is a brief description for each parameter as listed 
  87.   above:
  88.  
  89. #handle - any valid file handle may be used.  You must use the same handle
  90.       as will be used for the window that the button will belong to.
  91.  
  92. label   - Type the label desired for the button here.  Do not bound the word
  93.       with quotes, and do not use a string variable.
  94.  
  95. return  - Again, use only one word and do not bound it with quotes or use a
  96.       string variable.  If return is set to a valid branch label, then when
  97.       the button is pressed, execution will restart there (just as with
  98.       GOTO or GOSUB), but if return is not a valid branch label, then the 
  99.       value of return is used as input to a specified variable (as in 
  100.       input a$).
  101.  
  102. corner  - UL, UR, LL, or LR specifies which corner of the window to anchor
  103.       the button to.  For example, if LR is used, then the button will 
  104.       appear in the lower right corner.  UL = upper left, UR = upper 
  105.       right, LL = lower left, and LR = lower right
  106.  
  107. posx, posy - These two parameters determine how to place the button relative to
  108.       the corner it has been anchored to.  For example if corner is LR, 
  109.       posx is 5, and posy is 5, then the button will be 5 pixels up and 
  110.       left of the lower right corner.  Another way to use posx & posy is
  111.       to use values less than one.  For example, if corner is UL, posx
  112.       is .9, and posy is .9, then the button will be positioned 9/10th of 
  113.       the distance of the window in both x and y from the upper left
  114.       corner (and thus appear to be anchored to the lower right corner). 
  115.  
  116.  
  117.  
  118.  
  119.  
  120. BUTTON Continued
  121.  
  122. Here is a sample program:
  123.  
  124.   ' this button will be labeled Sample and will be located
  125.   ' in the lower right corner.  When it is pressed, program
  126.   ' execution will transfer to [test]
  127.     button #graph, Sample, [test], LR, 5, 5
  128.  
  129.   ' this button will be labeled Example and will be located
  130.   ' in the lower left corner.  When it is pressed, the string
  131.   ' "Example" will be returned.
  132.     button #graph, Example, Example, LL, 5, 5
  133.  
  134.   ' open a window for graphics
  135.     open "Button Sample" for graphics as #graph
  136.  
  137.   ' print a message in the window
  138.     print #graph, "\This is a test"
  139.  
  140.   ' get button input
  141. [loop]
  142.   input b$
  143.   if b$ = "Example" then [example]
  144.   goto [loop]
  145.  
  146.  ' the Sample button has been pressed, ring the terminal bell
  147.  ' and close the window
  148. [test]
  149.   beep
  150.   close #graph
  151.   end
  152.  
  153.  ' The Example button has been pressed, close the window
  154.  ' without ringing the bell
  155. [example]
  156.   close #graph
  157.   end
  158.  
  159.  
  160. CHR$( n )
  161.  
  162. Description:
  163.  
  164.   Returns a one character long string, consisting of the character 
  165.   represented on the ASCII table by the value n (0 - 255).
  166.  
  167. Usage:
  168.  
  169.   ' print each seperate word in text$ on its own line
  170.   text$ = "now is the time for all great men to rise"
  171.   for index = 1 to len(text$)
  172.       c$ = mid$(text$, index, 1)
  173.       ' if c$ is a space, change it to a carraige return
  174.       if c$ = chr$(32) then c$ = chr$(13)
  175.       print c$ ;
  176.   next index                            Produces:
  177.  
  178.                 now
  179.                 is
  180.                 the
  181.                 time
  182.                 for
  183.                 all
  184.                 great
  185.                 men
  186.                 to
  187.                 rise
  188.  
  189.  
  190. CLOSE #handle
  191.  
  192. Description:
  193.  
  194.   This command is used to close files and devices.  This is the last step of 
  195.   a file read and/or write, or to close graphic, spreadsheet, or other 
  196.   windows when finished with them.  If when execution of a program is 
  197.   complete there are any files or devices left open, Liberty BASIC will 
  198.   display a dialog informing you that it found it necessary to close the 
  199.   opened files or devices.  This is designed as an aid for you so that you 
  200.   will be able to correct the problem.  If on the other hand you choose to 
  201.   terminate the program early (this is done by closing the program's main 
  202.   window before the program finishes), then Liberty BASIC will close any open 
  203.   files or devices without posting a notice to that effect.
  204.  
  205. Usage:
  206.  
  207.   open "Graphic" for graphics as #gWindow       ' open a graphics window
  208.   print #gWindow, "home"                ' center the pen
  209.   print #gWindow, "down"                ' put the pen down
  210.   for index = 1 to 100                  ' loop 100 times
  211.     print #gWindow, "go "; index                ' move the pen foreward
  212.     print #gWindow, "turn 63"           ' turn 63 degrees
  213.   next index
  214.   input "Press 'Return'."; r$           ' this appears in main window
  215.   close #gWindow                        ' close graphic window
  216.  
  217.  
  218. CLS
  219.  
  220. Description:
  221.  
  222.   Clears the main program window of text and sets the cursor back at the 
  223.   upper left hand corner.  Useful  for providing a break to seperate 
  224.   different sections of a program functionally.  Additionally, since the main 
  225.   window doesn't actually discard past information on its own, the CLS 
  226.   command can be used to reclaim memory from your program by forcing the main 
  227.   window to dump old text.
  228.  
  229. Usage:
  230.  
  231.   .
  232.   .
  233.   print "The total is: "; grandTotal
  234.   input "Press 'Return' to continue."; r$
  235.   cls
  236.   print "*** Enter Next Round of Figures ***"
  237.   .
  238.   .
  239.  
  240.  
  241. CONFIRM string; responseVar
  242.  
  243. Description:
  244.  
  245.   This statement opens a dialog box displaying the contents of string and 
  246.   presenting two buttons marked 'Yes' and 'No'.  When the selection is made, 
  247.   the string "yes" is returned if 'Yes' is pressed, and the string "no" is 
  248.   returned if 'No' is pressed.  The result is placed in responseVar.
  249.  
  250. Usage:
  251.  
  252. [quit]
  253.  
  254.   ' bring up a confirmation box to be sure that
  255.   ' the user want to quit
  256.   confirm "Are you sure you want to QUIT?"; answer$
  257.   if answer$ = "no" then [mainLoop]
  258.   end
  259.  
  260.  
  261. COS( n )
  262.  
  263. Description:
  264.  
  265.   Returns the cosine of the number n.
  266.  
  267. Usage:
  268.  
  269.   .
  270.   .
  271.   for c = 1 to 45
  272.     print "The cosine of "; c; " is "; cos(c)
  273.   next c
  274.   .
  275.   .
  276.  
  277. Note:
  278.  
  279.   See also SIN( ) and TAN( )
  280.  
  281.  
  282. DATE$( )
  283.  
  284. Description:
  285.  
  286.   Instead of adopting MBASIC's date$ variable, we decided to use a function 
  287.   instead, figuring that this might give us additional flexibility later.  
  288.   This function returns the current date in long format.
  289.  
  290. Usage:
  291.  
  292.   print date$( )
  293.  
  294. Produces:
  295.  
  296.   Feb 5, 1991
  297.  
  298.  
  299. DIM array(size, size)
  300.  
  301. Description:
  302.  
  303.   DIM sets the maximum size of an array.  Any array can be dimensioned to 
  304.   have as many elements as memory allows.  If an array is not DIMensioned 
  305.   explicitly, then the array will be limited to 10 elements, 0 to 9.  Non 
  306.   DIMensioned double subscript arrays will be limited to 100 elements 0 to 9 
  307.   by 0 to 9.
  308.  
  309. Usage:
  310.  
  311.   print "Please enter 10 names."
  312.   for index = 0 to 9
  313.     input names$ : name$(index) = name$
  314.   next index
  315.  
  316.   The FOR . . . NEXT loop in this example is limited to a maximum value of 9 
  317.   because the array names$( ) is not dimensioned, and therefore is limited to 
  318.   10 elements.  To remedy this problem, we can add a DIM statement, like so:
  319.  
  320.   dim names$(20)
  321.   print "Please enter 20 names."
  322.   for index = 0 to 19
  323.     input names$ : names$(index) = name$
  324.   next index
  325.  
  326. Double subscripted arrays can store information more flexibly, like so:
  327.  
  328.   dim customerInfo$(10, 5)
  329.   print "Please enter information for 10 customers."
  330.   for index = 0 to 9
  331.     input "Customer name >"; info$ : customerInfo$(index, 0) = info$
  332.     input "Address >"; info$ : customerInfo$(index, 1) = info$
  333.     input "City >"; info$ : customerInfo$(index, 2) = info$
  334.     input "State >"; info$ : customerInfo$(index, 3) = info$
  335.     input "Zip >"; info$ : customerInfo$(index, 4) = info$
  336.   next index
  337.  
  338.  
  339. ELSE
  340.  
  341.     See IF . . . THEN . . . ELSE
  342.  
  343.  
  344. EOF(#handle)
  345.  
  346. Description:
  347.  
  348.   Used to determine when reading from a sequential file whether the end of 
  349.   the file has been reached.  If so, -1 is returned, otherwise 0 is returned.
  350.  
  351. Usage:
  352.  
  353.   open "testfile" for input as #1
  354.   if eof(#1) < 0 then [skipIt]
  355. [loop]
  356.   input #1, text$
  357.   print text$
  358.   if eof(#1) = 0 then [loop]
  359. [skipIt]
  360.   close #1
  361.  
  362.  
  363. END
  364.  
  365. Description:
  366.  
  367.   Used to immediately terminate execution of a program.  If any files or 
  368.   devices are still open (see CLOSE) when execution is terminated, then 
  369.   Liberty BASIC will close them for you and present you with a dialog 
  370.   expressing this fact.  It is good programming practice to close files and 
  371.   devices before terminating execution.
  372.  
  373.   Note:  The STOP statement is functionally identical to END and is 
  374.   interchangable
  375.  
  376. Usage:
  377.  
  378.   .
  379.   .
  380.   print "Preliminary Tests Complete."
  381. [askAgain]
  382.   input "Would you like to continue (Y/N) ?"; yesOrNo$
  383.   yesOrNo$ = left$(yesOrNo$, 1)
  384.   if yesOrNo$ = "y" or yesOrNo$ = "Y" then [continueA]
  385.   ifYesOrNo$ = 'n" or yesOrNo$ = "N" then end
  386.   print "Please answer Y or N."
  387.   goto [askAgain]
  388. [continueA]
  389.   .
  390.   .
  391.  
  392.  
  393. FOR . . . NEXT
  394.  
  395. Description:
  396.  
  397.   The FOR . . . NEXT looping construct provides a way to repeatedly execute 
  398.   code a specific amount times.  A starting and ending value are specified 
  399.   like so:
  400.  
  401.   for var = 1 to 10
  402.     {BASIC code}
  403.   next var
  404.  
  405.   In this case, the {BASIC code} is executed 10 times, with var being 1 the 
  406.   first time, 2 the second, and on through 10 the tenth time.  Optionally 
  407.   (and usually) var is used in some calculation(s) in the {BASIC code}.  
  408.   For example if the {BASIC code} is  print var ^ 2, then a list of squares 
  409.   for var will be displayed upon execution.
  410.  
  411.   The specified range could just as easily be 2 TO 20, instead of 1 TO 10, 
  412.   but since the loop always counts +1 at a time, the first number must be 
  413.   less than the second.  The way around this limitation is to place STEP n 
  414.   at the end of for FOR statement like so:
  415.  
  416.   for index = 20 to 2 step -1
  417.     {BASIC code}
  418.   next index
  419.  
  420.   This would look from 19 times returning values for index that start with 
  421.   20 and end with 2.  STEP can be used with both positive and and negative 
  422.   numbers and it is not limited to integer values.  For example:
  423.  
  424.   for x = 0 to 1 step .01
  425.     print "The sine of "; x; " is "; sin(x)
  426.   next x
  427.  
  428.  
  429.  
  430.  
  431. Note:
  432.  
  433.   It is not recommended to pass control of a program out of a FOR . . . NEXT
  434. loop using GOTO (GOSUB is acceptable).  Liberty BASIC may behave unpredictably.
  435.  
  436.  
  437. GOSUB label
  438.  
  439. Description:
  440.  
  441.   GOSUB causes execution to proceed to the program code following the label
  442. if it exists,  using the form 'GOSUB label'.  The label can be either a
  443. traditional line number or a branch label in the format [???????] where the
  444. ?'s can be any upper/lowercase letter combination.  Spaces and numbers are
  445. not allowed.
  446.  
  447. Here are some valid branch labels:  [mainMenu]  [enterLimits]  [repeatHere]
  448. Here are some invalid branch labels:  [enter limits]  mainMenu  [1moreTime]
  449.  
  450.   After execution is transferred to the point of the branch label, then each 
  451.   statement will be executed in normal fashion until a RETURN is encountered.  
  452.   When this happens, execution is transferred back to the statement 
  453.   immediately after the GOSUB.  The section of code between a GOSUB and its 
  454.   RETURN is known as a 'subroutine.'  One purpose of a subroutine is to save 
  455.   memory by having only one copy of code that is used many times throughout a 
  456.   program.
  457.  
  458. Usage:
  459.  
  460.   .
  461.   .
  462.   print "Do you want to continue?"
  463.   gosub [yesOrNo]
  464.   if answer$ = "N" then [quit]
  465.   print "Would you like to repeat the last sequence?"
  466.   gosub [yesOrNo]
  467.   if answer$ = "Y" then [repeat]
  468.   goto [generateNew]
  469.  
  470. [yesOrNo]
  471.   input answer$
  472.   answer$ = left$(answer$, 1)
  473.   if answer$ = "y" then answer$ = "Y"
  474.   if answer$ = "n" then answer$ = "N"
  475.   if answer$ = "Y" or answer$ = "N" then return
  476.   print "Please answer Y or N."
  477.   goto [yesOrNo]
  478.   .
  479.   .
  480.  
  481.   You can see how using GOSUB [yesOrNo] in this case saves many lines of code 
  482.   in this example.  The subroutine [yesOrNo] could easily be used many other 
  483.   times in such a hypothetical program, saving memory and reducing typing 
  484.   time and effort.  This reduces errors and increases productivity.  See also 
  485.   GOTO
  486.  
  487.  
  488. GOTO label
  489.  
  490. Description:
  491.  
  492.   GOTO causes Liberty BASIC to proceed to the program code following the label 
  493.   if one exists,  using the form 'GOTO label'.  The label can be either a 
  494.   traditional line number or a branch label in the format [???????] where the 
  495.   ?'s can be any upper/lowercase letter combination.  Spaces and digits are 
  496.   not allowed.
  497.  
  498. Here are some valid branch labels:  [mainMenu]  [enterLimits]  [repeatHere]
  499. Here are some invalid branch labels:  [enter limits]  mainMenu  [1moreTime]
  500.  
  501. Usage:
  502.  
  503.   .
  504.   .
  505. [repeat]
  506.   .
  507.   .
  508. [askAgain]
  509.   print "Make your selection (m, r, x)."
  510.   input selection$
  511.   if selection$ = "M" then goto [menu]
  512.   if selection$ = "R" then goto [repeat]
  513.   if selection$ = "X" then goto [exit]
  514.   goto [askAgain]
  515.   .
  516.   .
  517. [menu]
  518.   print "Here is the main menu."
  519.   .
  520.   .
  521. [exit]
  522.   print "Okay, bye."
  523.   end
  524.  
  525. Notes:
  526.  
  527.   In the lines containing IF . . . THEN GOTO, the GOTO is optional.  
  528.   The expression IF . . . THEN [menu]  is just as valid as 
  529.   IF . . . THEN GOTO [menu].  But in the line GOTO [askAgain], the GOTO 
  530.   is required. 
  531.  
  532.   See also GOSUB
  533.  
  534.  
  535. IF expression THEN expression(s)
  536.  
  537. Description:
  538.  
  539.   The purpose of IF . . . THEN is to provide a mechanism for your computer 
  540.   software to make decisions based on the data available.  A decision-making 
  541.   mechanism is used in very simple situations and can be used in combinations 
  542.   to engineer solutions to problems of great complexity.
  543.  
  544.   The expression (see above) is a boolean expression (meaning that it 
  545.   evaluates to a true or false condition).  In this expression we place the 
  546.   logic of our decision-making process.  For example, if we are writing a 
  547.   inventory application, and we need to know when any item drops below a 
  548.   certain level in inventory, then our decision-making logic might look like 
  549.   this:
  550.  
  551.   .
  552.   .
  553.   if level <= reorderLevel then expression(s)
  554.   next BASIC program line
  555.   .
  556.   .
  557.  
  558.   The 'level <= reorderLevel' part of the above expression will evaluate to 
  559.   either true or false.  If the result was true, then the expression(s) part 
  560.   of that line (consisting of a branch label or any valid BASIC statements) 
  561.   will be executed.  Otherwise execution will immediately begin at the next 
  562.   BASIC program line.
  563.  
  564.   The following are permitted:
  565.  
  566.   if a < b then [lessThan]      
  567.  
  568.   This causes program execution to begin at branch label [lessThan]
  569. if a is less than b
  570.  
  571.   if sample < lowLimit or sample > highLimit then beep : print"Out of range!"
  572.  
  573.   This causes the terminal bell to ring and the message Out of range! to be 
  574.   displayed if sample is less than lowLimit or greater then highLimit.
  575.  
  576.  
  577. IF expression THEN expression(s)1 ELSE expression(s)2
  578.  
  579. Description:
  580.  
  581.   This extended form of IF . . . THEN adds expressiveness and simplifies 
  582.   coding of some logical decision-making software.  Here is an example of its 
  583.   usefulness.
  584.  
  585.   Consider:
  586.  
  587. [retry]
  588.   input"Please choose mode, (N)ovice or e(X)pert?"; mode$
  589.   if len(mode$) = 0 then print "Invalid entry! Retry" : goto [retry]
  590.   mode$ = left$(mode$, 1)
  591.   if instr("NnXx", mode$) = 0 then print "Invalid entry! Retry" : goto [retry]
  592.   if instr("Nn", mode$) > 0 then print "Novice mode" : goto [main]
  593.   print "eXpert mode"
  594. [main]
  595.   print "Main Selection Menu"
  596.  
  597.   Look at the two lines before the [main] branch label.  The first of these 
  598.   two lines is required to branch over the next line.  These lines can be 
  599.   shortened to one line as follows:
  600.  
  601.   if instr("Nn",mode$)> 0 then print "Novice mode" else print "eXpert mode"
  602.  
  603.   Some permitted forms are as follows:
  604.  
  605.   if a < b then statement else statement
  606.   if a < b then [label] else statement
  607.   if a < b then statement else [label]
  608.   if a < b then statement : statement else statement
  609.   if a < b then statement else statement : statement
  610.   if a < b then statement : goto [label] else statement
  611.   if a < b then gosub [label1] else gosub [label2]
  612.  
  613.   Any number of variations on these formats are permissible.  The a < b 
  614.   boolean expression is of course only a simple example chosen for convenience.  
  615.   You must replace it with the correct expression to suit your problem.
  616.  
  617.  
  618. INPUT  #handle  "string expression";  variableName
  619.  
  620. Description:
  621.  
  622.   This command has three possible forms:
  623.  
  624.   input var             - stop and wait for user to enter data in the program's
  625.           main window and press the 'Return' key, then assign
  626.           the data entered to var.
  627.  
  628.   input "enter data"; var   - display the string "enter data" and then stop
  629.           and wait for user to enter data in the program's main window
  630.           and press 'Return', then assign the data entered to var.
  631.  
  632.   input #name, var    - or -    input #name, var1, var2
  633.  
  634.    - Get the next data item from the open file or device using handle named 
  635.      #handle and assign the data to var.  If no device or file exists that 
  636.      uses the handle named #handle, then return an error.  In the second case, 
  637.      the next two data items are fetched and assigned to var1 and var2.
  638.  
  639. Usage:
  640.  
  641.   'Display a text file
  642.   input "Please type a filename >";  filename$
  643.   open filename$ for input as #text
  644. [loop]
  645.   if eof(#text) <> 0 then [quit]
  646.   input #text, item$
  647.   print item$
  648.   goto [loop]
  649. [quit]
  650.   close #text
  651.   print "Done."
  652.   end
  653.  
  654.  
  655. Note:  In Liberty BASIC release 1.0, INPUT cannot be used to input data 
  656. directly into arrays, only into the simpler variables.
  657.  
  658.   input a$(1)                   - is illegal
  659.   input string$ : a$(1) = string$       - use this instead
  660.  
  661. This shortcoming will be addressed in a future release.  This should not be a 
  662. problem anyway if you will be checking the input for validity before 
  663. ultimately accepting it.
  664.  
  665. INPUT (continued)
  666.  
  667. Most versions of Microsoft BASIC implement INPUT to automatically place a 
  668. question mark on the display in front of the cursor when the user is prompted 
  669. for information like so:
  670.  
  671.   input "Please enter the upper limit"; limit
  672.  
  673.   produces:
  674.  
  675.     Please enter the upper limit ? |
  676.  
  677. Liberty BASIC permits you the luxury of deciding for yourself whether the 
  678. question mark appears at all.
  679.  
  680.   input "Please enter the upper limit :"; limit
  681.  
  682.   produces:
  683.  
  684.     Please enter the upper limit: |
  685.  
  686.   and:    input limit    produces simply:
  687.  
  688.     ? |
  689.  
  690. In the simple form input limit, the question mark is inserted automatically,  
  691. but if you do specify a prompt, as in the above example, only the contents of 
  692. the prompt are displayed, and nothing more.  If for some reason you wish to 
  693. input without a prompt and without a question mark, then the following will 
  694. achieve the desired effect:
  695.  
  696.   input ""; limit 
  697.  
  698. Additionally, in most Microsoft BASICs, if INPUT expects a numeric value and 
  699. a non numeric or string value is entered, the user will be faced with a 
  700. comment something like 'Redo From Start', and be expected to reenter.  
  701. Liberty BASIC does not automatically do this, but converts the entry to a zero 
  702. value and sets the variable accordingly.  This is not considered a problem but 
  703. rather a language feature, allowing you to decide for yourself how your 
  704. program will respond to the situation.
  705.  
  706. One last note:  In Liberty BASIC input prompt$; limit is also valid. Try:
  707.  
  708.   prompt$ = "Please enter the upper limit:"
  709.   input prompt$; limit
  710.  
  711.  
  712. INPUT$(#handle, items)
  713.  
  714. Description:
  715.  
  716.   Permits the retrieval of a specified number of items from an open file or 
  717.   device using #handle.  If #handle does not refer to an open file or device 
  718.   then an error will be reported.
  719.  
  720. Usage:
  721.  
  722.   'read and display a file one character at a time
  723.   open "c:\autoexec.bat" for input as #1
  724. [loop]
  725.     if eof(#1) <> 0 then [quit]
  726.     print input$(#1, 1);
  727.     goto [loop]
  728. [quit]
  729.     close #1
  730.     end
  731.  
  732. For most devices (unlike disk files), one item does not refer a single 
  733. character, but INPUT$( ) may return items more than one character in length.  
  734. In most cases, use of INPUT #handle, varName works just as well or better for 
  735. reading devices.
  736.  
  737.  
  738. INSTR(string1, string2, starting)
  739.  
  740. Description:
  741.  
  742.   This function returns the position of string2 within string1.  If string2 
  743.   occurs more than once in string 1, then only the position of the leftmost 
  744.   occurance will be returned.  If starting is included, then the search for 
  745.   string2 will begin at the position specified by starting.
  746.  
  747. Usage:
  748.  
  749.   print instr("hello there", "lo")
  750.  
  751.   produces:    4
  752.  
  753.   print instr("greetings and meetings", "eetin")
  754.  
  755.   produces:    3
  756.  
  757.   print instr("greetings and meetings", "eetin", 5)
  758.  
  759.   produces:    16
  760.  
  761. If string2 is not found in string1, or if string2 is not found after starting,
  762. then INSTR( ) will return 0.
  763.  
  764.   print instr("hello", "el", 3)
  765.  
  766.   produces:    0
  767.  
  768.   and so does:
  769.  
  770.   print instr("hello", "bye") INT(number)
  771.  
  772. Description:
  773.  
  774.   This function removes the fractional part of number, leaving only the whole
  775.   number part behind.
  776.  
  777. Usage:
  778.  
  779. [retry]
  780.   input "Enter an integer number>"; i
  781.   if i<>int(i) then bell: print i; " isn't an integer! Re-enter.": goto [retry]
  782.  
  783.  
  784. LEFT$(string, number)
  785.  
  786. Description:
  787.  
  788.   This function returns from string the specified number of characters starting
  789.   from the left.  So if  string is "hello there", and number is 5, then "hello"
  790.   would be the result.
  791.  
  792. Usage:
  793.  
  794.  
  795. [retry]
  796.   input "Please enter a sentence>"; sentence$
  797.   if sentence$ = "" then [retry]
  798.   for i = 1 to len(sentence$)
  799.     print left$(sentence$, i)
  800.   next i
  801.  
  802. Produces:
  803.  
  804.   Please enter a sentence>That's all folks!
  805.   T
  806.   Th
  807.   Tha
  808.   That
  809.   That'
  810.   That's
  811.   That's_
  812.   That's a
  813.   That's al
  814.   That's all
  815.   That's all_
  816.   That's all f
  817.   That's all fo
  818.   That's all fol
  819.   That's all folk
  820.   That's all folks
  821.   That's all folks!
  822.  
  823. Note:
  824.  
  825.   If number is zero or less, then "" (an empty string) will be returned.  If 
  826.   the number is greater than the number of characters in string, then string
  827.   will be returned.
  828.  
  829.   See also MID$( ) and RIGHT$( )
  830.  
  831.  
  832. LEN( string )
  833.  
  834. Description:
  835.  
  836.   This function returns the length in characters of string, which can be any 
  837.   valid string expression.
  838.  
  839. Usage:
  840.  
  841.   prompt "What is your name?"; yourName$
  842.   print "Your name is "; len(yourName$); " letters long"
  843.  
  844.  
  845. LET assignment expression
  846.  
  847. Description:
  848.  
  849.   LET is an optional prefix for any BASIC assignment expression.  Most do leave
  850.   the word out of their programs, but some prefer to use it.
  851.  
  852. Usage:
  853.  
  854.   Either is acceptable:
  855.  
  856.   let name$ = "John"    
  857. or
  858.   name$ = "John"
  859.  
  860.   Or yet again:
  861.  
  862.   let c = sqr(a^2 + b^2)
  863. or
  864.   c = sqr(a^2 + b^2)
  865.  
  866.  
  867. MID$(string, index, number)
  868.  
  869. Description:
  870.  
  871.   Permits the extraction of a sequence of characters from string starting at 
  872.   index.  If number is not specified, then all the characters from index to the
  873.   end of the string are returned.  If number is specified, then only as many
  874.   characters as number specifies will be returned, starting from index.
  875.  
  876. Usage:
  877.  
  878.   print mid$("greeting Earth creature", 10, 5)
  879.  
  880. Produces:
  881.  
  882.   Earth
  883.  
  884. And:
  885.  
  886.   string = "The quick brown fox jumped over the lazy dog"
  887.   for i = 1 to len(string$) step 5
  888.     print mid$(string$, i, 5)
  889.   next i
  890.  
  891. Produces:
  892.  
  893.   The_q
  894.   uick_
  895.   brown
  896.   _fox_
  897.   jumpe
  898.   d_ove
  899.   r_the
  900.   _lazy
  901.   _dog
  902.  
  903.  
  904. Note:
  905.  
  906.   See also LEFT$( ) and RIGHT$( ) NEXT var
  907.  
  908.     see  FOR . . . NEXT
  909.  
  910.  
  911. OPEN string FOR purpose AS #handle
  912.  
  913. Description:
  914.  
  915.   This statement has many functions.  It can be used to open disk files, or to
  916.   open windows of several kinds.
  917.  
  918. Disk files:
  919.  
  920.   A typical OPEN used in disk I/O looks like this:
  921.  
  922.   OPEN "\autoexec.bat" for input as #read
  923.  
  924.   This example illustrates how we would open the autoexec.bat file for reading.  
  925.   As you can see, string in this case is "\autoexec.bat", purpose is input, and 
  926.   #handle is read.
  927.  
  928.   string - this must be a valid pathname.  If the file does not exist, it will 
  929.        be created.
  930.  
  931.   purpose - must be input, output, or random
  932.  
  933.   #handle - use a unique descriptive word, but must start with a #.  
  934.         This special handle is used to identify the open file in later 
  935.         program statements
  936.  
  937. Windows:
  938.  
  939.   A typical OPEN used in windows looks like this:
  940.  
  941.   OPEN "Customer Statistics Chart" for graphics as #csc
  942.  
  943.   This example illustrates how we would open a window for graphics.  Once the 
  944.   window is open, there are a wide range of commands that can be given to it 
  945.   (see chapter ? - Liberty BASIC Graphics for more about this).  As you can 
  946.   see, string in this case is "Customer Statistics Chart", which is used as 
  947.   the title of the window, purpose is graphics (open a window for graphics), 
  948.   and the #handle is #csc (derived from Customer Statistics Chart), which will 
  949.   be used as an identifier when sending commands to the window.
  950.  
  951.   string - can be any valid BASIC string.  used to label the window
  952.   purpose - there are a several of possibilities here:
  953.         graphics, spreadsheet, text
  954.         any of these can end in _fs, _nsbars (or other suffixes)
  955.   #handle - as above, must be a unique, descriptive word starting with #
  956.  
  957.  
  958. Note:  Any opened file or window must be closed before program execution is 
  959. finished.  See CLOSE
  960.  
  961.  
  962. PRINT #handle, pression ; expression(s) ;
  963.  
  964. Description:
  965.  
  966.   This statement is used to send data to the main window, to a disk file, or 
  967.   to other windows.  A series of expressions can follow PRINT (there does not 
  968.   need to be any expression at all), each seperated by a semicolon.  Each 
  969.   expression is displayed in sequence.  If the data is being sent to a disk 
  970.   file, or to a window, then #handle must be present.
  971.  
  972. PRINTing to a the main window:
  973.   When the expressions are displayed, then the cursor (that blinking vertical 
  974.   bar | ) will move down to the next line, and the next time information is 
  975.   sent to the window, it will be placed on the next line down.  If you do not 
  976.   want the cursor to move immediately to the next line, then add an additional 
  977.   semicolor to the end of the list of expressions.  This prevents the cursor 
  978.   from being moved down a line when the expressions are displayed.  The next 
  979.   time data is displayed, it will be added onto the end of the line of data 
  980.   displayed previously.
  981.  
  982. Usage:                  Produces:
  983.  
  984.   print "hello world"           hello world
  985.  
  986.   print "hello ";               hello world
  987.   print "world"
  988.   
  989.   age = 23
  990.   print "Ed is "; age; " years old"     Ed is 23 years old
  991.  
  992. When sending to a disk file and in regard to the use of the semicolon at the 
  993. end of the expression list, the rules are similar (only you don't see it 
  994. happen on the screen).  When printing to a window, the expressions sent are 
  995. usually commands to the window (or requests for information from the window).  
  996. For more information, see chapter ?, Liberty BASIC Graphics.
  997.  
  998.  
  999. PROMPT string; responseVar
  1000.  
  1001. Description:
  1002.  
  1003.   The PROMPT statement opens a dialog box, displays string, and waits for the 
  1004.   user to type a response and press 'Return' (or press the OK or Cancel 
  1005.   button).  The entered information is placed in responseVar.  If Cancel is 
  1006.   pressed, then a string of zero length is returned.  If responseVar is set to 
  1007.   some string value before PROMPT is executed, then that value will become the 
  1008.   'default' or suggested response.  This means that when the dialog is opened, 
  1009.   the contents of responseVar will already be entered as a response for the 
  1010.   user, who then has the option to either type over that 'default' response, to 
  1011.   to press 'Return' and accept it.
  1012.  
  1013. Usage:
  1014.  
  1015.   .
  1016.   .
  1017.   response$ = "C:"
  1018.   prompt "Search on which Drive? A:, B:, or C:"; response$
  1019. [testResponse]
  1020.   if response$ = "" then [cancelSearch]
  1021.   if len(response$) = 2 and instr("A:B:C:", response$) > 0 then [search]
  1022.   prompt "Unacceptable response.  Please try again. A:, B:, or C:"; again$
  1023.   goto [testResponse]
  1024.  
  1025. [search]
  1026.   print "Starting search . . . "
  1027.   .
  1028.   .
  1029.  
  1030.  
  1031. REM comment
  1032.  
  1033. Description:
  1034.  
  1035.   The REM statement is used to place comments inside of code to clearly 
  1036.   explain the purpose of each section of code.  This is useful to both the 
  1037.   programmer who writes the code or to anyone who might later need to modify 
  1038.   the program.  Use REM statements liberally.  There is a shorthand way of 
  1039.   using REM, which is to use the ' (apostrophe) character in place of the word 
  1040.   REM.  This is cleaner to look at, but use whichever you prefer.  Unlike other 
  1041.   BASIC statements, with REM you cannot add another statement after it on the 
  1042.   same line using a colon ( : ) to seperate the statements.  The rest of the 
  1043.   line becomes part of the REM statement.
  1044.  
  1045. Usage:
  1046.  
  1047.   rem  let's pretend that this is a comment for the next line
  1048.   print "The mean average is "; meanAverage
  1049.  
  1050. Or:
  1051.  
  1052.   ' let's pretend that this is a comment for the next line
  1053.   print "The strength of the quake was "; magnitude
  1054.  
  1055. This doesn't work:
  1056.  
  1057.   rem  thank the user : print "Thank you for using Super Stats!"
  1058.  
  1059.     (even the print statement becomes part of the REM statement)
  1060.  
  1061.  
  1062. Note:
  1063.  
  1064.   When using ' instead of REM at the end of a line, the statement seperator :
  1065. is not required to seperate the statement on that line from its comment.  
  1066.  
  1067. For example:
  1068.  
  1069.   print "Total dollar value: "; dollarValue : rem  print the dollar value
  1070.  
  1071. Can also be stated:
  1072.  
  1073.   print "Total dollar value: "; dollarValue  ' print the dollar value
  1074.  
  1075. Notice that the : is not required in the second form.
  1076.  
  1077.  
  1078. RETURN
  1079.  
  1080.     See  GOSUB
  1081.  
  1082.  
  1083. RIGHT$(string, number)
  1084.  
  1085. Description:
  1086.  
  1087.   Returns a sequence of characters from the right hand side of string using 
  1088.   number to determine how many characters to return.  If  number is 0, 
  1089.   then "" (an empty string) is returned.  If number is greater than the number 
  1090.   of characters in string, then string will itself be returned.
  1091.  
  1092. Usage:
  1093.  
  1094.   print right$("I'm right handed", 12)
  1095.  
  1096. Produces:
  1097.  
  1098.   right handed
  1099.  
  1100. And:
  1101.  
  1102.   print right$("hello world", 50)
  1103.  
  1104. Produces:
  1105.  
  1106.   hello world
  1107.  
  1108. Note:
  1109.  
  1110.   See also LEFT$( ) and MID$( )
  1111.  
  1112.  
  1113. RND(number)
  1114.  
  1115. Description:
  1116.  
  1117.   This function returns a pseudo random number between 0 and 1.  This can be 
  1118.   useful in writing games and some simulations.  The particular formula used 
  1119.   in this release might more accurately be called an arbitrary number generator 
  1120.   (instead of random number generator), since if a distribution curve of the 
  1121.   output of this function were plotted, the results would be quite uneven.  
  1122.   Nevertheless, this function should prove more than adequate (especially for 
  1123.   game play).
  1124.  
  1125.   In MBASIC it makes a difference what the value of parameter number is, but 
  1126.   in Liberty BASIC, it makes no difference.  The function will always return 
  1127.   an arbitrary number between 0 and 1.
  1128.  
  1129. Usage:
  1130.  
  1131.   ' print ten numbers between one and ten
  1132.   for a = 1 to 10
  1133.       print int(rnd(1)*10) + 1
  1134.   next a
  1135.   
  1136. SIN(number)
  1137.  
  1138. Description:
  1139.  
  1140.   This function return the sine of number.
  1141.  
  1142. Usage:
  1143.  
  1144.   .
  1145.   .
  1146.   for t = 1 to 45
  1147.     print "The sine of "; t; " is "; sin(t)
  1148.   next t
  1149.   .
  1150.   .
  1151.  
  1152. Note:
  1153.  
  1154.   See also COS( ) and TAN( )
  1155.  
  1156.  
  1157. STR$(numericExpression)
  1158.  
  1159. Description:
  1160.  
  1161.   This function returns a string expressing the result of  numericExpression.  
  1162.   In MBASIC, this function would always return a string representation of the 
  1163.   expression and it would add a space in front of that string.  For example 
  1164.   in MBASIC:
  1165.  
  1166.   print len(str$(3.14))
  1167.  
  1168.   Would produce the number 5 (a space followed by 3.14 for a total of 5 
  1169.   characters).
  1170.  
  1171.   Liberty BASIC leaves it to you to decide whether you want that space or not.  
  1172.   If you don't want it, then you need not do anything at all, and if you do 
  1173.   want it, then this expression will produce the same result under Liberty 
  1174.   BASIC:
  1175.  
  1176.   print len(" " + str$(3.14))
  1177.  
  1178. Usage:
  1179.  
  1180.   .
  1181.   .
  1182. [kids]
  1183.   ' use str$( ) to validate entry
  1184.   input "How many children do you have?"; qtyKids
  1185.   qtyKids$ = str$(qtyKids)
  1186.   ' if the entry contains a decimal point, then the response is no good
  1187.   if instr(qtyKids$, ".") > 0 then print "Bad response. Reenter." : goto [kids]
  1188.   .
  1189.   .
  1190.  
  1191.  
  1192. TAN(number)
  1193.  
  1194. Description:
  1195.  
  1196.   This function return the tangent of number.
  1197.  
  1198. Usage:
  1199.  
  1200.   .
  1201.   .
  1202.   for t = 1 to 45
  1203.     print "The tangent of "; t; " is "; tan(t)
  1204.   next t
  1205.   .
  1206.   .
  1207.  
  1208. Note:
  1209.  
  1210.   See also SIN( ) and COS( )
  1211. TIME$( )
  1212.  
  1213. Description:
  1214.  
  1215.   This function returns a string representing the current time of the system 
  1216.   clock in 24 hour format.  This function replaces the time$ variable used in 
  1217.   MBASIC.  See also DATE$( ).
  1218.  
  1219. Usage:
  1220.  
  1221.   .
  1222.   .
  1223.   ' display the opening screen
  1224.   print "Main selection screen             Time now: "; time$( )
  1225.   print
  1226.   print "1. Add new record"
  1227.   print "2. Modify existing record"
  1228.   print "3. Delete record"
  1229.   .
  1230.   .
  1231.  
  1232.  
  1233. TRACE number
  1234.  
  1235. Description:
  1236.  
  1237.   This statement sets the trace level for its application program.  This is 
  1238.   only effective if the program is run using the Debug menu selection 
  1239.   (instead of RUN).  If Run is used, then any TRACE statements are ignored by 
  1240.   the interpreter.
  1241.  
  1242.   There are three trace levels: 0, 1, and 2.  Here are the effects of these 
  1243.   levels:
  1244.  
  1245.   0 = single step mode or STEP
  1246.   1 = animated trace or WALK
  1247.   2 = full speed no trace or RUN
  1248.  
  1249.   When any Liberty BASIC program first starts under Debug mode, the trace
  1250.   level is always initially 0.  You can then click on any of the three buttons
  1251.   (STEP, WALK, RUN) to determine what mode to continue in.   When a TRACE
  1252.   statement is encountered, the trace level is set accordingly, but you can
  1253.   recover from this new trace level by clicking again on the desired button.
  1254.  
  1255.   If you are having trouble debugging code at a certain spot, then you can add 
  1256.   a TRACE statement (usually level 0) just before that location, run in Debug 
  1257.   mode and then click on RUN.  When the TRACE statement is reached, then the 
  1258.   debugger will kick in at that point.
  1259.  
  1260. Usage:
  1261.  
  1262.   .
  1263.   .
  1264.   'Here is the trouble spot
  1265.   trace 0  ' kick down to single step mode
  1266.   for index = 1 to int(100*sin(index))
  1267.     print #graph, "go "; index ; " "; int(100*cos(index))
  1268.   next index
  1269.   .
  1270.   .
  1271.  
  1272.  
  1273. TRIM$(stringExpression)
  1274.  
  1275. Description:
  1276.  
  1277.   This function removes any spaces from the start and end of the string in 
  1278.   stringExpression.  This can be useful for cleaning up data entry among other 
  1279.   things.
  1280.  
  1281.  
  1282. Usage:
  1283.  
  1284.   sentence$ = "  Greetings  "
  1285.   print len(trim$(sentence$))
  1286.  
  1287. Produces:
  1288.  
  1289.   9
  1290.  
  1291.  
  1292. USING(templateString, numericExpression)
  1293.  
  1294. Description:
  1295.  
  1296.   This function formats numericExpression as a string using templateString.  
  1297.   The rules for the format are like those in MBASIC's PRINT USING statement, 
  1298.   but since USING( ) is a function, it can be used as part of a larger BASIC 
  1299.   expression instead of being useful only for output directly.
  1300.  
  1301.  
  1302. Usage:
  1303.  
  1304.   ' print a column of ten justified numbers
  1305.   for a = 1 to 10
  1306.       print using("####.##",  rnd(1)*1000)
  1307.   next a
  1308.  
  1309.  
  1310. VAL(stringExpression)
  1311.  
  1312. Description:
  1313.  
  1314.   This function returns a numeric value for stringExpression is 
  1315.   stringExpression represents a valid numeric value or if it starts out as 
  1316.   one.  If not, then zero is returned.  This function lets your program take 
  1317.   string input from the user and carefully analyze it before turning it into 
  1318.   a numeric value if and when appropriate. 
  1319.  
  1320. Usage:
  1321.  
  1322.   print 2 * val("3.14")         Produces:       6.28
  1323.  
  1324.   print val("hello")            Produces:       0
  1325.  
  1326.   print val("3 blind mice")     Produces:       3
  1327.  
  1328.  
  1329. WHILE expression . . . WEND
  1330.  
  1331. Description:
  1332.  
  1333.   These two statements comprise the start and end of a control loop.  Between 
  1334.   the WHILE and WEND statements place code (optionally) that will be executed 
  1335.   repeatedly while expression evaluates the same.  Expression can be a boolean, 
  1336.   numeric, or string expression.
  1337.  
  1338. Usage:
  1339.  
  1340.   ' loop until midnight (go read a good book)
  1341.   while time$ <> "00:00:00"
  1342.       ' some action performing code might be placed here
  1343.   wend
  1344.  
  1345. Or:
  1346.  
  1347.   ' loop until a valid response is solicited
  1348.   while val(age$) = 0
  1349.      input "How old are you?"; age$
  1350.      if val(age$) = 0 then print "Invalid response.  Try again."
  1351.   wend
  1352.  
  1353. Or:
  1354.  
  1355.   ' generate a list of ten non-consecutive random numbers
  1356.   for count = 1 to 10
  1357.     while random : random = int(rnd(1)*10)+1 : wend
  1358.     print random
  1359.   next count
  1360.  
  1361. WORD$( stringExpression, n )
  1362.  
  1363. Description:
  1364.  
  1365.   This function returns the nth word in stringExpression.  The leading and
  1366.   trailing spaces are stripped from stringExpression and then it is broken
  1367.   down into 'words' at the remaining spaces inside.  If n is less than 1 or
  1368.   greater than the number of words in stringExpression, then "" is returned.
  1369.  
  1370. Usage:
  1371.  
  1372.   print word$("The quick brown fox jumped over the lazy dog", 5)
  1373.  
  1374. Produces:
  1375.  
  1376.   jumped
  1377.  
  1378. And:
  1379.  
  1380.   ' display each word of sentence$ on its own line
  1381.   sentence$ = "and many miles to go before I sleep."
  1382.   tkn$ = "?"
  1383.   while tkn$ <> ""
  1384.       index = index + 1
  1385.       tkn$ = word$(sentence$, index)
  1386.       print tkn$
  1387.   wend
  1388.  
  1389. Produces:
  1390.  
  1391.   and
  1392.   many
  1393.   miles
  1394.   to
  1395.   go
  1396.   before
  1397.   I
  1398.   sleep.
  1399.  
  1400.   Summary of Window Device Commands
  1401.   --------------------------------------------------------------------
  1402.  
  1403.   In Liberty BASIC windows are treated like files, and we can refer
  1404.   to anything in this class as a BASIC 'Device'.  To open a window
  1405.   we use the OPEN statement, and to close the window we use the
  1406.   CLOSE statement.  To control the window we 'print' to it, just as
  1407.   we would print to a file.  The commands are sent as strings to the
  1408.   device.  As a simple example, here we will open a graphics window,
  1409.   center a pen (like a Logo turtle), and draw a simple spiral.  We
  1410.   will then pause by opening a simple dialog.  When you confirm the
  1411.   exit, we will close the window:
  1412.  
  1413.     button #graph, Exit, [exit], LR, 5, 5    'window will have a button 
  1414.     open "Example" for graphics as #graph    'open graphics window
  1415.     print #graph, "up"                     'make sure pen is up
  1416.     print #graph, "home"                   'center the pen
  1417.     print #graph, "down"                   'make sure pen is down
  1418.     for index = 1 to 30                    'draw 30 spiral segments
  1419.       print #graph, "go "; index           'go foreward 'index' places
  1420.       print #graph, "turn 118"             'turn 118 degrees
  1421.     next index                             'loop back 30 times
  1422.     print #graph, "flush"                  'make the image 'stick'
  1423.  
  1424.   [inputLoop]
  1425.     input b$ : goto [inputLoop]            'wait for button press
  1426.  
  1427.   [exit]
  1428.     confirm "Close Window?"; answer$       'dialog to confirm exit
  1429.     if answer$ = "no" then [inputLoop]     'if answer$ = "no" loop back
  1430.     close #graph
  1431.  
  1432.   end
  1433.  
  1434.  
  1435.   Here we used only a few of the commands available to us.  Here are
  1436.   three seperate lists, one for Graphics, one for Spreadsheet, and one
  1437.   for Text windows:
  1438.  
  1439.  
  1440.  
  1441.   GRAPHICS
  1442.   ------------------------------------------------------------------------
  1443.   
  1444.  
  1445.   print #handle, "cls"
  1446.  
  1447.     Clear the graphics window to white, erasing all drawn elements
  1448.  
  1449.  
  1450.   print #handle, "fill COLOR"
  1451.  
  1452.     Fill the window with COLOR.  For a list of accepted colors see
  1453.     the color command below.
  1454.  
  1455.  
  1456.   print #handle, "home"
  1457.  
  1458.     Center (or re-center) the pen in the window.
  1459.  
  1460.  
  1461.   print #handle, "up"
  1462.  
  1463.     Lift the pen up from the drawing surface.  All go or goto commands
  1464.     will only move to their new positions without drawing when the pen
  1465.     is up.
  1466.  
  1467.  
  1468.   print #handle, "down"
  1469.  
  1470.     Just the opposite of up.  This command causes lines to be drawn
  1471.     when the pen is moved.
  1472.  
  1473.  
  1474.   print #handle, "color COLOR"
  1475.  
  1476.     Set the pen's color to be COLOR.
  1477.  
  1478.     Here is a list of valid colors (in alphabetical order):
  1479.  
  1480.       black, blue, brown, cyan, darkblue, darkcyan, darkgray,
  1481.       darkgreen, darkpink, darkred, green, lightgray, palegray,
  1482.       pink, red, white, yellow
  1483.  
  1484.  
  1485.   print #handle, "goto X Y"
  1486.  
  1487.     Move the pen to position X Y.  Draw if the pen is down.
  1488.  
  1489.  
  1490.   print #handle, "place X Y"
  1491.  
  1492.     Position the pen at X Y.  Do not draw even if the pen is down.
  1493.  
  1494.  
  1495.   print #handle, "go D"
  1496.  
  1497.     Go foreward D distance from the current position using the current
  1498.     direction.
  1499.  
  1500.  
  1501.   print #handle, "north"
  1502.  
  1503.     Set the current direction to 270 (north).  Zero degrees points to the
  1504.     right (east), 90 points down (south), and 180 points left (west).
  1505.  
  1506.  
  1507.   print #handle, "turn A"
  1508.  
  1509.     Turn from the current direction using angle A and adding it to the
  1510.     current direction.  A can be positive or negative.
  1511.  
  1512.  
  1513.   print #handle, "line X1 Y1 X2 Y2"
  1514.  
  1515.     Draw a line from point X1 Y1 to point X2 Y2.  If the pen is up, then
  1516.     no line will be drawn, but the pen will be positioned at X2 Y2.
  1517.  
  1518.  
  1519.   print #handle, "circle r"
  1520.  
  1521.     Draw a circle whose center is the location of the pen and whose radius
  1522.     is r.
  1523.  
  1524.  
  1525.   print #handle, "posxy"
  1526.  
  1527.     Return the current position of the pen in X & Y.  This command must
  1528.     be followed by:
  1529.  
  1530.     input #handle, xVar, yVar
  1531.  
  1532.     which will assign the pen's position to xVar & yVar
  1533.  
  1534.  
  1535.   print #handle, "size S"
  1536.  
  1537.     Set the size of the pen to S.  The default is 1.
  1538.  
  1539.  
  1540.   print #handle, "flush"
  1541.  
  1542.     This ensures that the drawn graphics 'stick'.  Make sure to issue this
  1543.     command at the end of a drawing sequence to ensure that when the window
  1544.     is resized or  overlapped and redrawn, its image will be retained.
  1545.  
  1546.  
  1547.   print #handle, "print"
  1548.  
  1549.     Send the plotted image to the Windows Print Manager for output.
  1550.  
  1551.  
  1552.   print #handle, "font facename width height"
  1553.  
  1554.     Set the pen's font to the specified face, width and height.  If an
  1555.     exact match cannot be found, then Liberty BASIC will try to find a
  1556.     close match, with size being of more prominance than face.
  1557.  
  1558.  
  1559.   SPREADSHEET  
  1560.   ----------------------------------------------------------------------
  1561.  
  1562.   The spreadsheet used in Liberty BASIC is composed of 35 rows of 26
  1563.   columns labeled from A to Z.  The upper-left-most cell is A1 and
  1564.   the lower-right-most cell is Z35.  Each cell can contain one of three
  1565.   types of data:  string, number, or formula.  To enter one of these
  1566.   three types into any cell, simply move the selector over the cell on
  1567.   the spreadsheet and begin typing.  When done entering that cell's
  1568.   contents, press 'Return'.
  1569.  
  1570.    A string is entered by preceding it with an apostrophe '.  Each cell
  1571.    is 11 characters wide so if the string is longer than 11 characters
  1572.    it will run into the next cell to its right.
  1573.  
  1574.    A number is entered by entering its value, either an integer or a
  1575.    floating point number.
  1576.  
  1577.    A formula is a simple mathematical expression, using numbers (see
  1578.    above) or cell references.  The result of the formula is displayed
  1579.    in the cell's position. Any arithmetic precedence is ignored, so
  1580.    any formula is always evaluated from left to right and parenthesis
  1581.    are not permitted (They aren't needed).
  1582.  
  1583.      A sample formula to compute the average of 3 cells might be:    
  1584.      a1 + a2 + a3 / 3       
  1585.  
  1586.   The spreadsheet is a very special widget.  Alone it is a very simple
  1587.   but complete spreadsheet.  But being able to send it commands and data
  1588.   and to be able to read back data from it via Liberty BASIC makes it
  1589.   a very powerful tool.  For examples, see GRAPHER.BAS and CUSTOMER.BAS.
  1590.  
  1591.   Modes:
  1592.   The spreadsheet has two modes, manual and indirect.  Manual mode means
  1593.   that the operator can freely move about from cell to cell using the
  1594.   arrow keys.  He/she can also insert formulas in manual mode.  Using
  1595.   indirect mode, the user can only move between cells defined by the
  1596.   controlling application, which also decides what type of data is
  1597.   contained by each cell, either string or number.
  1598.  
  1599.  
  1600.   Here are the commands:
  1601.  
  1602.  
  1603.   print $handle, "manual"
  1604.  
  1605.     The manual mode is the default setting.  This mode permits the
  1606.     user to move the cell selector wherever he/she wants and to
  1607.     enter any of three data types into any cell: number, string, formula
  1608.  
  1609.  
  1610.   print #handle, "format COLUMN right|fixed|none"
  1611.  
  1612.     This command lets the application control formatting for an individual
  1613.     column (COLUMN can be any letter A .. Z).  
  1614.  
  1615.     right - right justify column
  1616.     fixed - assume 2 decimal places for numbers, and right justify also
  1617.     none - left justify, default
  1618.  
  1619.  
  1620.   print #handle, "indirect"
  1621.  
  1622.     The indirect mode is the most useful when using a spreadsheet for
  1623.     data entry.  It enables the application to control which cells the
  1624.     user has access to, and what kind of information they can contain.
  1625.  
  1626.  
  1627.   print #handle, "cell ADDRESS CONTENTS"
  1628.  
  1629.     Place CONTENTS into the cell at ADDRESS.  ADDRESS can be any cell
  1630.     address from A1 to Z35.  The letter A to Z must be in uppercase.
  1631.     CONTENTS can be any valid string, number or formula (see above).
  1632.  
  1633.  
  1634.   print #handle, "user ADDRESS string|number"
  1635.   
  1636.     Set aside the cell at ADDRESS (same rules apply as for ADDRESS in
  1637.     command cell, above) as a user cell and specify the data it
  1638.     contains to be either a string or a number (data entered will be
  1639.     automatically converted to correct type).  This command is only
  1640.     effective when indirect mode is in effect (see above).
  1641.  
  1642.  
  1643.   print #handle, "select ADDRESS"
  1644.  
  1645.     Place the selector over the cell at ADDRESS (again, same rules).
  1646.     It is important to place the selector over the first cell that
  1647.     the user will edit.
  1648.  
  1649.  
  1650.   print #handle, "result? ADDRESS"
  1651.  
  1652.     Answer the result or value of the cell at ADDRESS (again, same
  1653.     rules).  If ADDRESS is not a valid cell address, then an empty
  1654.     string will be returned.  This command must be followed by:
  1655.  
  1656.     input #handle, var$  (or  input #handle, var  if number expected)
  1657.  
  1658.     which will leave the desired cell's contents in var$  (or var)
  1659.  
  1660.  
  1661.   print #handle, "formula? ADDRESS"
  1662.  
  1663.     Answer the formula of the cell at ADDRESS (again, same rules).
  1664.     This command must also be followed with:
  1665.  
  1666.     input #handle, var$  (should always be a string returned)
  1667.  
  1668.     which will leave the desired cell's formula in var$
  1669.  
  1670.  
  1671.   print #handle, "flush"
  1672.  
  1673.     This commands forces the spreadsheet to display its most up to
  1674.     date results.
  1675.  
  1676.  
  1677.  
  1678.   TEXT WINDOW
  1679.   ------------------------------------------------------------------------
  1680.  
  1681.   The text window works a little differently.  Whatever you print to a
  1682.   text window is displayed exactly as sent.  The way to send commands to
  1683.   a text window is to make the ! character the first character in the
  1684.   string.  For example:
  1685.  
  1686.   open "Example" for text as #1        'open a text window
  1687.     print #1, "Hello World"            'print Hello World in the window
  1688.     print #1, "!font helv 16 37"       'change the text window's font 
  1689.     print #1, "!line 1"                'read line 1
  1690.     input #1, string$
  1691.     print "The first line of our text window is:"
  1692.     print string$
  1693.     input "Press 'Return'"; r$
  1694.   close #1                             'close the window
  1695.  
  1696.  
  1697.   There are only four commands supported for text windows to date:
  1698.  
  1699.  
  1700.   print #handle, "!cls"
  1701.  
  1702.     Clears the text window of all text.
  1703.  
  1704.  
  1705.   print #handle, "!font faceName width height"
  1706.  
  1707.     Sets the font of the text window to the specified face of width and
  1708.     height.  If an exact match cannot be found, then Liberty BASIC will
  1709.     try to match as closely as possible, with size figuring more
  1710.     prominently than face in the match.
  1711.  
  1712.  
  1713.   print #handle, "!line #"
  1714.  
  1715.     Returns the text at line #.  If # is less than 1 or greater than the
  1716.     number of lines the text window contains, then "" (an empty string)
  1717.     is returned.  After this command is issued, it must be followed by:
  1718.  
  1719.     input #handle, string$
  1720.  
  1721.     which will assign the line's text to string$
  1722.  
  1723.  
  1724.   print #handle, "!lines"
  1725.  
  1726.     Returns the number of lines in the text window.  After this command
  1727.     is issued, it must be followed by:
  1728.  
  1729.     input #handle, countVar
  1730.  
  1731.     which will assign the line count to countVar
  1732.  
  1733.  
  1734.  
  1735.  
  1736.   TIPS
  1737.   ------------------------------------------------------------------------
  1738.   
  1739.   Once the techniques are mastered, the spreadsheet becomes a much better
  1740.   mechanism for data entry than do plain INPUT statements in a BASIC
  1741.   program's host window.  This is especially true when many items need to
  1742.   be entered.  In this case, making the spreadsheet the control center
  1743.   for your application might be a good idea.  Just add buttons to the
  1744.   spreadsheet to perform needed functions after data is entered.
  1745.  
  1746.   Remember, any window can have buttons (except for the host window, which
  1747.   is for some applications best kept minimized).  Take advantage of this.
  1748.   Release 0.9 does not have user definable pull down menus, but this will
  1749.   not be a problem for registered users.
  1750.  
  1751.   Don't forget to take advantage of the PROMPT and CONFIRM statements,
  1752.   which borrow the syntax from the INPUT statement, but do their thing in
  1753.   Windows dialogs.  These simple statements can help make your programs
  1754.   more Windows-like.
  1755.  
  1756.   When running GRAPHER.BAS, try pulling down the command menu and
  1757.   selecting Open.  Two .ABC files will be offered.  Load one of these
  1758.   and click on the Graph button.
  1759.